package gui.edit.components;


import gui.edit.enums.E_EditParamsCheckBoxes;
import gui.edit.enums.E_EditParamsSliders;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JPanel;
import javax.swing.JSeparator;

import tuio.components.BiSliderTouch;
import tuio.components.CheckBoxTouch;
import tuio.components.SliderTouch;

import com.visutools.nav.bislider.BiSlider;

import controls.DataControl;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class CameraPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1203484674156862231L;



	private DataControl dataControl;

	private BiSliderTouch pacingBiSlider;

	private SliderTouch minDurationOfShotSlider, dynamicitySlider, intensitySlider, shotTypeSlider, dutchAngleSlider;
	
	private CheckBoxTouch thirtyDegreesCheckBox, continuityOfLineOfInterestCheckBox, continuityOfLineOfActionCheckBox, continuityOfDirectionInScreenCheckBox, thirdsRuleCheckBox;

	public CameraPanel(DataControl dataControl){
		this.dataControl=dataControl;
		minDurationOfShotSlider = new SliderTouch();
		dataControl.getParamsControl().getMinDurationOfShotControl().setComponent(minDurationOfShotSlider);
		dynamicitySlider = new SliderTouch();
		dataControl.getParamsControl().getDynamicityControl().setComponent(dynamicitySlider);
		shotTypeSlider = new SliderTouch();
		dataControl.getParamsControl().getShotTypeControl().setComponent(shotTypeSlider);
		dutchAngleSlider = new SliderTouch();
		dataControl.getParamsControl().getDutchAngleControl().setComponent(dutchAngleSlider);
		intensitySlider = new SliderTouch();
		dataControl.getParamsControl().getIntensityControl().setComponent(intensitySlider);
		thirtyDegreesCheckBox = new CheckBoxTouch();
		dataControl.getParamsControl().getThirtyDegreesControl().setComponent(thirtyDegreesCheckBox);
		continuityOfLineOfInterestCheckBox = new CheckBoxTouch();
		dataControl.getParamsControl().getContinuityOfLineOfInterestControl().setComponent(continuityOfLineOfInterestCheckBox);
		continuityOfLineOfActionCheckBox = new CheckBoxTouch();
		dataControl.getParamsControl().getContinuityOfLineOfActionControl().setComponent(continuityOfLineOfActionCheckBox);
		continuityOfDirectionInScreenCheckBox = new CheckBoxTouch();
		dataControl.getParamsControl().getContinuityOfDirectionInScreenControl().setComponent(continuityOfDirectionInScreenCheckBox);
		thirdsRuleCheckBox = new CheckBoxTouch();
		dataControl.getParamsControl().getThirdsRuleControl().setComponent(thirdsRuleCheckBox);
		pacingBiSlider = new BiSliderTouch(BiSlider.RGB, false);
		dataControl.getParamsControl().getPacingControl().setComponent(pacingBiSlider);
		
		setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();

		c.gridx=0;
		c.gridy=0;
		c.fill=GridBagConstraints.VERTICAL;
		add(new ParamsBiSliders_PacingPanel(pacingBiSlider, dataControl.getParamsControl().getPacingControl(), E_EditParamsSliders.PACING),c);//TODO

		c.gridx+=1;
		add(new ParamsSliders_StandardLabelTablePanel(minDurationOfShotSlider, dataControl.getParamsControl().getMinDurationOfShotControl(), E_EditParamsSliders.MIN_SHOT_DURATION),c);

		c.gridx+=1;
		add(new JSeparator(JSeparator.VERTICAL),c);
		
		c.gridx+=1;
		add(new ParamsSliders_StandardLabelTablePanel(intensitySlider, dataControl.getParamsControl().getIntensityControl(), E_EditParamsSliders.INTENSITY));
		
		c.gridx+=1;
		add(new ParamsSliders_ShotTypePanel(shotTypeSlider, dataControl.getParamsControl().getShotTypeControl(),E_EditParamsSliders.SHOT_TYPE));
		
		c.gridx+=1;
		add(new ParamsSliders_StandardLabelTablePanel(dutchAngleSlider, dataControl.getParamsControl().getDutchAngleControl(), E_EditParamsSliders.DUTCH_ANGLE));
		
		c.gridx+=1;
		add(new JSeparator(JSeparator.VERTICAL),c);
		
		c.gridx+=1;
		add(new ParamsSliders_DynamicityPanel(dynamicitySlider, dataControl.getParamsControl().getDynamicityControl(),E_EditParamsSliders.DYNAMICITY),c);
		
		c.gridx+=1;
		add(new JSeparator(JSeparator.VERTICAL),c);
		
		c.gridx+=1;
		add(buildFilteringRulesPanel(),c);
	}
	
	public CameraPanel() {
		super();
		// TODO Auto-generated constructor stub
	}

	private JPanel buildFilteringRulesPanel() {
		JPanel panel = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		
		c.gridx=0;
		c.gridy=0;
		panel.add(new ParamsCheckBoxesPanel(thirtyDegreesCheckBox, dataControl.getParamsControl().getThirtyDegreesControl(),E_EditParamsCheckBoxes.THIRTY_DEGREES),c);

		c.gridy+=1;
		panel.add(new ParamsCheckBoxesPanel(continuityOfLineOfInterestCheckBox, dataControl.getParamsControl().getContinuityOfLineOfInterestControl(),E_EditParamsCheckBoxes.CONTINUITY_OF_LINE_OF_INTEREST),c);
		
		c.gridy+=1;
		panel.add(new ParamsCheckBoxesPanel(continuityOfLineOfActionCheckBox, dataControl.getParamsControl().getContinuityOfLineOfActionControl(),E_EditParamsCheckBoxes.CONTINUITY_OF_LINE_OF_ACTION),c);
		
		c.gridy+=1;
		panel.add(new ParamsCheckBoxesPanel(continuityOfDirectionInScreenCheckBox, dataControl.getParamsControl().getContinuityOfDirectionInScreenControl(),E_EditParamsCheckBoxes.CONTINUITY_OF_DIRECTION_IN_SCREEN),c);
		
		c.gridy+=1;
		c.fill=GridBagConstraints.HORIZONTAL;
		panel.add(new JSeparator(JSeparator.HORIZONTAL),c);
		
		c.gridy+=1;
		panel.add(new ParamsCheckBoxesPanel(thirdsRuleCheckBox, dataControl.getParamsControl().getThirdsRuleControl(),E_EditParamsCheckBoxes.THIRDS_RULE),c);
		
		return panel;
	}

	public void setDataControl(DataControl dataControl) {
		this.dataControl = dataControl;
	}

	public DataControl getDataControl() {
		return dataControl;
	}

}
